package com.allan.wiki_project.controller;

import com.allan.wiki_project.domain.Test;
import com.allan.wiki_project.service.TestService;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController //ResponseBody + Controller
//@Controller   返回的是页面 上面返回是字符串
public class TestController {
    @Resource
    private TestService testService;
    @Value("${test.hello:TEST5}")   //优先读配置文件，没有就这个冒号后的值
    private String testHello;
    @RequestMapping("/hello")
    public String hello() {
        return "hello motherfucker" + testHello;
    }

    @PostMapping("/hello/post")
    public String helloPost(String name){
        return "hello motherfucker post." + name;
    }

    @RequestMapping("/test/list")
    public List<Test> list(){
        return testService.list();
    }
}
